#pragma once

#include <iostream>
#include <iterator>
#include <list>
#include <ostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include "domtree.h"
#include "ir.h"
#include "irblock.h"
#include "irfunction.h"
#include "pass.h"

class DeadCodeEliminator : public Pass {
    DomTree T;
    std::unordered_map<IRBlock*, std::vector<IRBlock*>> CD, RCD;

    void BuildCD(IRFunction* func);

    void RunFunc(IRFunction* func);

  public:
    void* Run(void* input) override;
};
